// #define _GNU_SOURCE

#define _XOPEN_SOURCE   600
#define _POSIX_C_SOURCE 2008000L

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>

void delay_handler(int sig)
{
    int i = 0;

    bsd_signal(SIGINT, delay_handler);

    printf("begin delay handler...\n");
    for(i = 0; i < 5; i++) {
        printf("sleep %d...\n", i);
        sleep(1);
    }
    printf("end delay handler...\n");
}

int main(void)
{
    // signal(SIGINT, delay_handler);
    // sysv_signal(SIGINT, delay_handler);
    bsd_signal(SIGINT, delay_handler);

    while (1) {
        sleep(1);
    }

    return 0;
}

